package 蓝桥杯省赛;

import java.util.Arrays;
import java.util.Scanner;

public class 最短距离 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        long[] a = new long[n], b = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = scanner.nextLong();
        }
        for (int i = 0; i < n; i++) {
            b[i] = scanner.nextLong();
        }
        Arrays.sort(a);
        Arrays.sort(b);
        long res = 0;
        for (int i = 0; i < n; i++) {
            res += Math.abs(a[i] - b[i]);
        }
        System.out.println(res);
    }
}
